package cn.jiangxiong.pethome.utils;

import lombok.Data;

@Data
public class AjaxResult {
    private String msg;//返回消息
    private Boolean success;//成功或失败
   /* private T data;//返回数据的  使用泛型会导致方法无法使用静态修饰*/
    private Object data;
    private Long total;//总条数
    //私有化构造方法
    private AjaxResult() {
    }
    //私有化构造方法
    private AjaxResult(String msg, Boolean success) {
        this.msg = msg;
        this.success = success;
    }
    public static AjaxResult success(){
         return new  AjaxResult("成功",true);
    }
    public static AjaxResult error(){
        return new  AjaxResult("失败",false);
    }

    public AjaxResult setMsg(String msg) {
        this.msg = msg;
        return this;
    }

    public AjaxResult setSuccess(Boolean success) {
        this.success = success;
        return this;
    }

    public AjaxResult setData(Object data) {
        this.data = data;
        return this;
    }

    public AjaxResult setTotal(Long total) {
        this.total = total;
        return this;
    }
}
